<template>
    <div>
        <back-head title="配送区域" returnFlag="true"></back-head>        
        <el-row>
            <el-table
                ref="table"
                :data="dataList"
                border
                tooltip-effect="dark"
                style="width: 100%;">
                <el-table-column
                    prop="countryName"
                    label="国家名称">
                </el-table-column>
                <el-table-column
                    prop="provinceName"
                    label="省级名称">
                </el-table-column>
                <el-table-column
                    prop="cityName"
                    label="市级名称">
                </el-table-column>
                <el-table-column
                    prop="districtName"
                    label="区县名称">
                </el-table-column>
                <el-table-column
                    prop="townName"
                    label="街道或乡镇名称">
                </el-table-column>
                <el-table-column
                    prop="townId"
                    label="街道或乡镇id">
                </el-table-column>
            </el-table>
        </el-row>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                type: this.$route.query.type,
                productCode: this.$route.query.productCode,
                dataList : []
            }
        },
        created(){
            if(this.type == 1){   //通过session传值
                const arr = sessionStorage.getItem('deliveryAreaList');
                if(arr && arr != 'undefined'){
                    this.dataList = JSON.parse(arr).supportedDistricts
                }
            }else if(this.type == 2){     //通过axios传值
                this.$axios
                    .post("/admin/product/getProductSupportedDistrictsInfo.json",{
                        productCode: this.productCode
                    })
                    .then(res => {
                        const data = res.data;
                        if(data.success){
                            this.dataList = data.list;
                        }else{
                            this.$message.error(data.message);
                        }
                    })
            }
                
            
        }
    }

</script>


<style scoped>
    
</style>
